package com.wenheng.filter;

/**
 * @Auther: 文恒
 * @Date: 2021/3/22 - 03 - 22 -14:35
 * @Description:com.wenheng
 * @version:1.0
 */

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;


/**
 * 分页拦截器 初始化pageHelper中的相关配置
 */

public class PageInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String pageSize = request.getParameter("pageSize");
        String pageNum = request.getParameter("pageNum");
        System.out.println("pageSize:"+pageSize+",PageNum:"+pageNum);
        if(pageSize!=null && pageNum!=null)
        PageHelper.startPage(new Integer(pageNum),new Integer(pageSize));
        return true;
    }
}
